<template>
  <div>
    <button @click="btnClick">设置sessionStorage</button>
    <button @click="btnClick2">打开新窗口</button>
    <!-- cookie: -->
    <!--
      localstorage:永久存储，它有对应的api,大小很多浏览器5mb
      sessionStorage:临时存储，窗口会话级别，它也有对应 api
      cookie:没有对应api,存储它有时效设置，后端也可以设置前端的cookie,cookie主动参与接口请求，
          js-cookie
              1：下载
              2：导入
              3：使用
                 Cookies.get('key')                   ===>localStorage.getItem(key)
                 Cookies.set('key','value')           ===>localStorage.setItem(key, value)
                 Cookies.remove('key')                ===>localStorage.removeItem(key)
     -->
    <button @click="setCookie">设置cookie</button>
    <button @click="removeCookie">删除cookie</button>
  </div>
</template>
<script>
import Cookies from 'js-cookie'
export default {
  methods: {
    btnClick() {
      sessionStorage.setItem('test', '我是测试sessionStorage')
    },
    btnClick2() {
      window.open('http://localhost:8080/#/example/table')
    },
    setCookie() {
      Cookies.set('hr96cookie', 'cookie96')
      console.log(Cookies.get('hr96cookie'))
    },
    removeCookie() {
      Cookies.remove('hr96cookie')
      console.log(Cookies.get('hr96cookie'))
    }
  }
}
</script>
<style>
</style>
